import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:vischat/generated/icons/app_icons.dart';

/// 页面顶部搜索组件
class TopSearch extends StatelessWidget {

  final VoidCallback search;
  const TopSearch({super.key, required this.search});

  static final TextEditingController controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => search.call(),
      child: Container(
        width: double.infinity,
        padding: EdgeInsets.symmetric(horizontal: 15.w),
        margin: EdgeInsets.all(20.w),
        height: 60.h,
        alignment: Alignment.centerLeft,
        decoration: BoxDecoration(
          color: const Color(0xFFE0F1FA),
          borderRadius: BorderRadius.circular(40.r)
        ),
        child: TextField(
          controller: controller,
          decoration: InputDecoration(
            border: InputBorder.none,
            icon: Icon(AppIcons.search, size: 48.r,),
            contentPadding: EdgeInsets.zero,
            isDense: true
          ),
        ),
      ),
    );
  }
}